<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>深度监听-监听对象</title>
    <script src="./lib/vue-2.4.0.js"></script>
</head>
<body>
    <div id="app">
        <p v-for="(item,key) in user">
            {{item}}--{{key}}
        </p>
        <p>
            <input v-model='user.name' type="text" placeholder="输入新的姓名">
        </p>
    </div>
</body>
<script>
    var vm=new Vue({
        el:'#app',
        data:{
            user:{
                name:'jack',
                age:10
            }
        },
        methods:{
        },
        watch:{
            user:{
                handler(newVal,oldVal){
                    this.user=newVal;
                    console.log(newVal);
                    
                },
                //启用深度监听
                deep:true
            }
        }
    });
</script>
</html>